package com.koro.config;

import com.koro.filter.ExampleFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    // Filter代码类
    @Bean
    public ExampleFilter exampleFilter() {
        return new ExampleFilter();
    }

    @Bean
    public FilterRegistrationBean getFilterRegistrationBean(ExampleFilter exampleFilter) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(exampleFilter);
        filterRegistrationBean.setOrder(2);
        filterRegistrationBean.addUrlPatterns("/login");
        filterRegistrationBean.setName("exampleFilter");
        return filterRegistrationBean;
    }

}
